package gui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import java.sql.SQLException;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JTextArea;
import javax.swing.JList;
import javax.swing.JTextPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

import secretaryGUI.createSecretaryWindow;

import com.sun.rowset.CachedRowSetImpl;

import flexibility.CachedRowSetTableModel;
import guiCode.assignmentscode;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class assignmentsGUI extends JPanel{
	assignmentscode asc;
	TeacherMainMenuGUI tmmc;
	private JTable table;
	public JTable table_1;
	public JScrollPane scrollPane_1;
	public JButton button;
	
	public assignmentsGUI() {
		super();
		initialize();
	}
	private void initialize() {
		this.setSize(900,600);
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		JPanel panel = new JPanel();
		springLayout.putConstraint(SpringLayout.NORTH, panel, 75, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, panel, 22, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, panel, -105, SpringLayout.SOUTH, this);
		springLayout.putConstraint(SpringLayout.EAST, panel, 868, SpringLayout.WEST, this);
		add(panel);
		SpringLayout sl_panel = new SpringLayout();
		panel.setLayout(sl_panel);
		
		JLabel lblListOfAssignments = new JLabel("List of assignments for the selected course and semester:");
		sl_panel.putConstraint(SpringLayout.NORTH, lblListOfAssignments, 27, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.WEST, lblListOfAssignments, 190, SpringLayout.WEST, panel);
		panel.add(lblListOfAssignments);
		
		table_1 = new JTable();
		//table_1.setValueAt(arg0, arg1, arg2)
	/*	table_1.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				
						if(ssc.getEditMode()==2){
							row = table_1.rowAtPoint(e.getPoint());
							/**this will produce the studentID and the classID
							//System.outa.println(table_1.getValueAt(row, 0).toString());
							//System.out.println(classToEdit);
						//	ssc.addStudentToClass(Integer.parseInt(table_1.getValueAt(row, 0).toString()),classToEdit, ssc.getSemesterForEdit());
						//}
			}
		});*/
		
		table_1.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null},
				{null, null},
			},
			new String[] {
				"New column", "New column"
			}
		));
		
		scrollPane_1 = new JScrollPane(table_1);
		sl_panel.putConstraint(SpringLayout.NORTH, scrollPane_1, 57, SpringLayout.SOUTH, lblListOfAssignments);
		sl_panel.putConstraint(SpringLayout.WEST, scrollPane_1, 111, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, scrollPane_1, 213, SpringLayout.SOUTH, lblListOfAssignments);
		sl_panel.putConstraint(SpringLayout.EAST, scrollPane_1, 473, SpringLayout.WEST, panel);
		panel.add(scrollPane_1);
		
		button = new JButton("Back to the list of courses per semester");
		
		sl_panel.putConstraint(SpringLayout.NORTH, button, 64, SpringLayout.SOUTH, scrollPane_1);
		sl_panel.putConstraint(SpringLayout.WEST, button, 118, SpringLayout.WEST, panel);
		panel.add(button);
		
		//CachedRowSetImpl rs1=asc.getassignment(tmmc.s1,tmmc.s2);
		//asc.update(this,rs1);
		
	
		
		
		
		
	/*	table = new JTable();
		sl_panel.putConstraint(SpringLayout.NORTH, table, 374, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.WEST, table, 178, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, table, -338, SpringLayout.SOUTH, panel);
		sl_panel.putConstraint(SpringLayout.EAST, table, 305, SpringLayout.WEST, panel);
		table.setModel(new DefaultTableModel(new Object[][] {{null},{null}, },
				
				/*	JScrollPane	scrollPane = new JScrollPane(table);
		sl_panel.putConstraint(SpringLayout.NORTH, scrollPane, 410, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.WEST, scrollPane, 22, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, scrollPane, -362, SpringLayout.SOUTH, panel);
		sl_panel.putConstraint(SpringLayout.EAST, scrollPane, 461, SpringLayout.WEST, panel);
		panel.add(scrollPane);
		panel.add(table);*/
		
	}
}
